
<?php
if(!isset ($exportReportItems) || $exportReportItems->num_rows() == 0 ){
	?>
<script type="text/javascript">
	$(document).ready(function(){
		//addAnother('exportParenTableId' , 'exportHiddenTableId');
		
		addAnother('exportParentTableId' , 'exportHiddenTableId');
	});
</script>
	<?php } ?>


<script type="text/javascript">
	function addAnother(parentTableId , hiddenTableId){
		$("#"+parentTableId).append($("#"+hiddenTableId).html());
	}

	$(document).ready(function(){
		$("#fromWeek\\*").datepicker();
		$("#toWeek\\*").datepicker();
	});

	function displayDownloadDialog()
	{
			$( "#displayDownloadDialog" ).dialog({
				height: 225,
				width: 700,
				modal: true,
				buttons: [{
				text: "Download",
				click: function() {
				$("#downloadExportForm").submit(); }
				},{
				text: "Close",
				click: function() { $(this).dialog("close"); }
				}]
			});

	}

	
</script>



<!-- Container -->
<div id="container">
	<div class="shell">

		<!-- Small Nav -->
		<div class="small-nav">
			<a href="#">Dashboard</a> <span>&gt;</span> Current Reports
		</div>
		<?php
		$label = 'reports';
		include 'includes/message.php';
		?>
		<br />
		<!-- Main -->
		<div id="main">
			<div class="cl">&nbsp;</div>

			<!-- Content -->
			<div id="content">


			<?php
			if($action == ''){
				?>

				<!-- Box -->
				<div class="box" style="width: 1000px">
					<!-- Box Head -->
					<div class="box-head">
						<h2 class="left">
							Current Reports
							<h2>
					
					</div>
					<!-- End Box Head -->

					<!-- Table -->
					<div class="table" style="width: 100%">
						<table width="100%" border="0" cellspacing="0" cellpadding="0">
							<tr>
								<th>Date Created:</th>
								<th>From</th>
								<th>To</th>
								<th>Description</th>
								<th>Updated By</th>
								<th>Updated On</th>
								<th width="110" class="ac">Action</th>
							</tr>


							<?php
							if ($totalRecords > 0)
							{
								foreach ($query->result() as $report)
								{
									echo "
											<tr>
												<td>".$report->createdon."</td>
												<td>".$report->weekFrom."</td>
												<td>".$report->weekTo."</td>
												<td>".$report->description."</td>
												<td>".$report->updatedby."</td>
												<td>".$report->updatedon."</td>
												<td><a href='".ADMINBASEURL."reports/edit/".$report->id."'  class='ico edit'>edit</a> | <a href='".ADMINBASEURL."reports/delete/".$report->id."'  class='ico del'>delete</a></td>
											</tr>";


								}
							}

							?>




						</table>

						<?php
						include 'includes/pagination.php';
						?>

					</div>
					<!-- Table -->

				</div>
				<!-- End Box -->

				<?php
			}else{
				?>

				<!-- Box -->
				<div class="box" style="width: 1000px">
					<!-- Box Head -->
					<div class="box-head">
						<h2>
						<?php echo isset($report)? 'Edit' : 'Add New' ?>
							Report
						</h2>
					</div>
					<!-- End Box Head -->

					<form action="<?php echo ADMINBASEURL."$label/save/"; ?>"
						onsubmit="return MyForm.validate(this);" method="post">

						<!-- Form
Full Name	Username	Email	Usertype	Warehouse	Created By
						-->
						<div class="form">

						<?php
						if($action == 'edit' && isset($report))
						echo "<input type='hidden' name='id'  value='".$report->id."'>";
						?>
							<p>
								<input type="submit" value="Generate Report" class="button">
							
							
							<table>
								<tr>
									<TD>From :<input type="text" class="field size2"
										name="weekFrom" id="fromWeek*" style="width: 100px"
										maxlength="100" style="width:300px"
										value="<?php echo isset($report)?$report->weekFrom:''; ?>" />

									</TD>
									<TD>To: <input type="text" class="field size2"
										style="width: 100px" id="toWeek*" name="weekTo"
										maxlength="100" style="width:300px"
										value="<?php echo isset($report)?$report->weekTo:''; ?>" />
									</TD>
								</tr>
							</table>
							</p>

							<p>
								<label>Description <span>(Required Field)</span> </label>
								<textarea name="description" class="field size3" rows="5"
									style="width: 90%">
									<?php echo isset($report)?$report->description:''; ?>
								</textarea>
							</p>


							<p>
							
							
							<table width="100%" id="exportParentTableId">


							<?php
							if( isset ($exportReportItems) )
							foreach ($exportReportItems->result() as $reportItem)
							{
								?>


								<tr>
									<td><input type="hidden" name="reportItemId[]"
										value="<?php echo $reportItem->id;?>"> <label>Shipper </label>
										<select name="shipper[]" style="width: 150px"
										class="field size3">
										<?php
										foreach ($shippers->result() as $shipper)
										${"<option value='".$shipper->id."'".(($reportItem->shipper == $shipper->id))." >".$shipper->name."</option>"}
										?>
									</select>
									</td>
								</tr>
								<tr>
									<td valign="top">
										<table>
											<tr>
												<td style="width: 170px">Volume</td>
												<td>:</td>
												<td><input type='text'
													value="<?php echo $reportItem->volume;?>" name="volume[]"
													id="volume" class="field size5" style="widh: 100px"></td>
											</tr>
											<tr>
												<td>Commodity</td>
												<td>:</td>
												<td><input type='text'
													value="<?php echo $reportItem->commodity;?>"
													name="commodity[]" id="commodity" class="field size5"
													style="widh: 100px"></td>
											</tr>
											<tr>
												<td>Destinaion</td>
												<td>:</td>
												<td><input type='text'
													value="<?php echo $reportItem->destination;?>"
													name="destination[]" id="destination" class="field size5"
													style="widh: 100px"></td>
											</tr>
											<tr>
												<td>Vessel</td>
												<td>:</td>
												<td><input type='text'
													value="<?php echo $reportItem->vessel;?>" name="vessel[]"
													id="vessel" class="field size5" style="widh: 100px"></td>
											</tr>
											<tr>
												<td>Carrier</td>
												<td>:</td>
												<td><input type='text' name="carrier[]"
													value="<?php echo $reportItem->carrier;?>" id="carrier"
													class="field size5" style="widh: 100px"></td>
											</tr>
											<tr>
												<td>LCT</td>
												<td>:</td>
												<td><input type='text'
													value="<?php echo $reportItem->lct;?>" name="lct[]"
													id="lct" class="field size5" style="widh: 100px"></td>
											</tr>
											<tr>
												<td>ATD</td>
												<td>:</td>
												<td><input type='text'
													value="<?php echo $reportItem->atd;?>" name="atd[]"
													id="atd" class="field size5" style="widh: 100px"></td>
											</tr>
											<tr>
												<td colspan="3"><br>Comment<br></td>
											</tr>
											<tr>
												<td colspan="3"><textarea name="comment[]"
														class="field size3" style="width: 100%" rows="7">
														<?php echo $reportItem->comment;?>
													</textarea></td>
											</tr>
										</table>
									</td>
									<td>
										<table>
											<tr>
												<td><label>Status <span> </span> </label></td>
												<td></td>
												<td><label>Date Completed <span> </span> </label></td>
											</tr>
											<tr>
												<td>Booking Confirmation</td>
												<td>:</td>
												<td><input type='text'
													value="<?php echo $reportItem->status1;?>" name="status1[]"
													id="status1" class="field size5" style="widh: 100px"
													class="field size5" style="widh:100px"></td>
											</tr>
											<tr>
												<td>Check ATW Received</td>
												<td>:</td>
												<td><input type='text'
													value="<?php echo $reportItem->status2;?>" name="status2[]"
													id="status2" class="field size5" style="widh: 100px"></td>
											</tr>
											<tr>
												<td>Forward ATW to Shipper</td>
												<td>:</td>
												<td><input type='text'
													value="<?php echo $reportItem->status3;?>" name="status3[]"
													id="status3" class="field size5" style="widh: 100px"></td>
											</tr>
											<tr>
												<td>Update/ Monitor Shipper</td>
												<td>:</td>
												<td><input type='text'
													value="<?php echo $reportItem->status4;?>" name="status4[]"
													id="status4" class="field size5" style="widh: 100px"></td>
											</tr>
											<tr>
												<td>Follow Up final SI to Shipper</td>
												<td>:</td>
												<td><input type='text'
													value="<?php echo $reportItem->status5;?>" name="status5[]"
													id="status5" class="field size5" style="widh: 100px"></td>
											</tr>
											<tr>
												<td>Received final SI from Shipper</td>
												<td>:</td>
												<td><input type='text'
													value="<?php echo $reportItem->status6;?>" name="status6[]"
													id="status6" class="field size5" style="widh: 100px"></td>
											</tr>
											<tr>
												<td>Send final po-forma to Carrier</td>
												<td>:</td>
												<td><input type='text'
													value="<?php echo $reportItem->status7;?>" name="status7[]"
													id="status7" class="field size5" style="widh: 100px"></td>
											</tr>
											<tr>
												<td>Received B/L Copy from Carrier</td>
												<td>:</td>
												<td><input type='text'
													value="<?php echo $reportItem->status8;?>" name="status8[]"
													id="status8" class="field size5" style="widh: 100px"></td>
											</tr>
											<tr>
												<td>Encode Billing in BCIS</td>
												<td>:</td>
												<td><input type='text'
													value="<?php echo $reportItem->status9;?>" name="status9[]"
													id="status9" class="field size5" style="widh: 100px"></td>
											</tr>
											<tr>
												<td>Request for Telex Release</td>
												<td>:</td>
												<td><input type='text'
													value="<?php echo $reportItem->status10;?>"
													name="status10[]" id="status10" class="field size5"
													style="widh: 100px"></td>
											</tr>
											<tr>
												<td>Request payment for Carrier</td>
												<td>:</td>
												<td><input type='text'
													value="<?php echo $reportItem->status11;?>"
													name="status11[]" id="status11" class="field size5"
													style="widh: 100px"></td>
											</tr>
											<tr>
												<td>Revised B/L</td>
												<td>:</td>
												<td><input type='text' name="status12[]"
													value="<?php echo $reportItem->status12;?>" id=status12
													class="field size5" style="widh: 100px"></td>
											</tr>

										</table>
									</td>
								</tr>


								<?php
							}
							?>
















							</table>


							<table width="100%">
								<tr>
									<td valign="left"><a href="javascript:void(0)"
										onclick="addAnother('exportParentTableId' , 'exportHiddenTableId')">ADD
											ANOTHER EXPORT DETAILS</a></td>
								</tr>
							</table>

							</p>



						</div>
						<!-- End Form -->

						<!-- Form Buttons -->
						<div class="buttons">
							<input type="submit" class="button" value="submit" />

							<?php
							if($action == 'edit' && isset($report))
							echo '<input type="button" name="generateExcelReport" value="Generate Report" class="button" onclick="displayDownloadDialog()">';
							?>
						</div>
						<!-- End Form Buttons -->
					</form>
				</div>




				<div style="display: none">

					<table width="100%" id="exportHiddenTableId">
						<tr>
							<td><label>Shipper </label> <select name="shipper[]"
								style="width: 150px" class="field size3">
								<?php
								if(isset($shippers))
								foreach ($shippers->result() as $shipper)
								${"<option value='".$shipper->id."'>".$shipper->name."</option>"}
								?>
							</select>
							</td>
						</tr>
						<tr>
							<td valign="top">
								<table>
									<tr>
										<td style="width: 170px">Volume</td>
										<td>:</td>
										<td><input type='text' name="volume[]" id="volume"
											class="field size5" style="widh: 100px"></td>
									</tr>
									<tr>
										<td>Commodity</td>
										<td>:</td>
										<td><input type='text' name="commodity[]" id="commodity"
											class="field size5" style="widh: 100px"></td>
									</tr>
									<tr>
										<td>Destinaion</td>
										<td>:</td>
										<td><input type='text' name="destination[]" id="destination"
											class="field size5" style="widh: 100px"></td>
									</tr>
									<tr>
										<td>Vessel</td>
										<td>:</td>
										<td><input type='text' name="vessel[]" id="vessel"
											class="field size5" style="widh: 100px"></td>
									</tr>
									<tr>
										<td>Carrier</td>
										<td>:</td>
										<td><input type='text' name="carrier[]" id="carrier"
											class="field size5" style="widh: 100px"></td>
									</tr>
									<tr>
										<td>LCT</td>
										<td>:</td>
										<td><input type='text' name="lct[]" id="lct"
											class="field size5" style="widh: 100px"></td>
									</tr>
									<tr>
										<td>ATD</td>
										<td>:</td>
										<td><input type='text' name="atd[]" id="atd"
											class="field size5" style="widh: 100px"></td>
									</tr>
									<tr>
										<td colspan="3"><br>Comment<br></td>
									</tr>
									<tr>
										<td colspan="3"><textarea name="comment[]" class="field size3"
												style="width: 100%" rows="7"></textarea></td>
									</tr>
								</table>
							</td>
							<td>
								<table>
									<tr>
										<td><label>Status <span> </span> </label></td>
										<td></td>
										<td><label>Date Completed <span> </span> </label></td>
									</tr>
									<tr>
										<td>Booking Confirmation</td>
										<td>:</td>
										<td><input type='text' name="status1[]" id="status1"
											class="field size5" style="widh: 100px" class="field size5"
											style="widh:100px"></td>
									</tr>
									<tr>
										<td>Check ATW Received</td>
										<td>:</td>
										<td><input type='text' name="status2[]" id="status2"
											class="field size5" style="widh: 100px"></td>
									</tr>
									<tr>
										<td>Forward ATW to Shipper</td>
										<td>:</td>
										<td><input type='text' name="status3[]" id="status3"
											class="field size5" style="widh: 100px"></td>
									</tr>
									<tr>
										<td>Update/ Monitor Shipper</td>
										<td>:</td>
										<td><input type='text' name="status4[]" id="status4"
											class="field size5" style="widh: 100px"></td>
									</tr>
									<tr>
										<td>Follow Up final SI to Shipper</td>
										<td>:</td>
										<td><input type='text' name="status5[]" id="status5"
											class="field size5" style="widh: 100px"></td>
									</tr>
									<tr>
										<td>Received final SI from Shipper</td>
										<td>:</td>
										<td><input type='text' name="status6[]" id="status6"
											class="field size5" style="widh: 100px"></td>
									</tr>
									<tr>
										<td>Send final po-forma to Carrier</td>
										<td>:</td>
										<td><input type='text' name="status7[]" id="status7"
											class="field size5" style="widh: 100px"></td>
									</tr>
									<tr>
										<td>Received B/L Copy from Carrier</td>
										<td>:</td>
										<td><input type='text' name="status8[]" id="status8"
											class="field size5" style="widh: 100px"></td>
									</tr>
									<tr>
										<td>Encode Billing in BCIS</td>
										<td>:</td>
										<td><input type='text' name="status9[]" id="status9"
											class="field size5" style="widh: 100px"></td>
									</tr>
									<tr>
										<td>Request for Telex Release</td>
										<td>:</td>
										<td><input type='text' name="status10[]" id="status10"
											class="field size5" style="widh: 100px"></td>
									</tr>
									<tr>
										<td>Request payment for Carrier</td>
										<td>:</td>
										<td><input type='text' name="status11[]" id="status11"
											class="field size5" style="widh: 100px"></td>
									</tr>
									<tr>
										<td>Revised B/L</td>
										<td>:</td>
										<td><input type='text' name="status12[]" id=status12
											class="field size5" style="widh: 100px"></td>
									</tr>

								</table>
							</td>
						</tr>
					</table>
				</div>




				<!-- End Box -->

				<?php
			}
			?>

			</div>
			<!-- End Content -->

			<!-- Sidebar -->
			<div id="sidebar">


				<!-- End Box -->
			</div>
			<!-- End Sidebar -->

			<div class="cl">&nbsp;</div>
		</div>
		<!-- Main -->
	</div>
</div>


<!-- DIALOG  --->
<div id="displayDownloadDialog" title="Download Export Report"
	style="display: none">
	<div class="form">
		<form id="downloadExportForm"
			action="<?php echo ADMINBASEURL?>reports" method="post">
			<input type="hidden" name="download" value="download"> <input
				type="hidden" name="id"
				value="<?php echo isset($report)?$report->id:'';?>">
			<table width="100%">
				<tr>
					<td colspan="4"><label>Date</label></td>
				</tr>
				<tr>
					<td><label>From</label></td>
					<td><input type="text" class="field size1" style="width: 150px"
						name="fromDate" id="fromDateDownload"></td>
					<td><label>To</label></td>
					<td><input type="text" class="field size1" style="width: 150px"
						name="toDate" id="toDateDownload"></td>
				</tr>
			</table>
		</form>
	</div>
</div>


<!-- End Container -->



